home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / oper_sys / kerberos / pc / krb_libk.lha / Lib / KRB / KNTOLN.C < prev    next >
Encoding:
C/C++ Source or Header  |  1991-06-07  |  1.8 KB  |  63 lines

  1. /*
  2.  * $Source: /mit/kerberos/src/lib/krb/RCS/kntoln.c,v $
  3.  * $Author: jtkohl $
  4.  *
  5.  * Copyright 1985, 1986, 1987, 1988 by the Massachusetts Institute
  6.  * of Technology.
  7.  *
  8.  * For copying and distribution information, please see the file
  9.  * <mit-copyright.h>.
  10.  */
  11.  
  12. #ifndef lint
  13. static char *rcsid_kntoln_c =
  14. "$Header: kntoln.c,v 4.7 89/01/23 09:25:15 jtkohl Exp $";
  15. #endif /* lint */
  16.  
  17. #include <mit_copy.h>
  18. #include <krb.h>
  19. #include <string.h>
  20.  
  21. /*
  22.  * krb_kntoln converts an auth name into a local name by looking up
  23.  * the auth name in the /etc/aname file.  The format of the aname
  24.  * file is:
  25.  *
  26.  * +-----+-----+-----+-----+------+----------+-------+-------+
  27.  * | anl | inl | rll | lnl | name | instance | realm | lname |
  28.  * +-----+-----+-----+-----+------+----------+-------+-------+
  29.  * | 1by | 1by | 1by | 1by | name | instance | realm | lname |
  30.  * +-----+-----+-----+-----+------+----------+-------+-------+
  31.  *
  32.  * If the /etc/aname file can not be opened it will set the
  33.  * local name to the auth name.  Thus, in this case it performs as
  34.  * the identity function.
  35.  *
  36.  * The name instance and realm are passed to krb_kntoln through
  37.  * the AUTH_DAT structure (ad).
  38.  *
  39.  * Now here's what it *really* does:
  40.  *
  41.  * Given a Kerberos name in an AUTH_DAT structure, check that the
  42.  * instance is null, and that the realm is the same as the local
  43.  * realm, and return the principal's name in "lname".  Return
  44.  * KSUCCESS if all goes well, otherwise KFAILURE.
  45.  */
  46.  
  47. krb_kntoln(ad,lname)
  48.     AUTH_DAT *ad;
  49.     char *lname;
  50. {
  51.     static char lrealm[REALM_SZ] = "";
  52.  
  53.     if (!(*lrealm) && (krb_get_lrealm(lrealm,1) == KFAILURE))
  54.         return(KFAILURE);
  55.  
  56.     if (strcmp(ad->pinst,""))
  57.         return(KFAILURE);
  58.     if (strcmp(ad->prealm,lrealm))
  59.         return(KFAILURE);
  60.     (void) strcpy(lname,ad->pname);
  61.     return(KSUCCESS);
  62. }
  63.